import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:rjpb/shared/styles/z_box_shadow.dart';
import 'package:rjpb/shared/styles/z_gradient.dart';
import 'package:rjpb/components/z_button/z_ink_button.dart';

class ZButton extends StatefulWidget {
  const ZButton({
    super.key,
    this.buttonType = ButtonType.blue,
    this.height = 43,
    required this.text,
    this.style,
    this.padding,
    this.onPressed,
  });
  final ButtonType buttonType;
  final double height;
  final String text;
  final TextStyle? style;
  final EdgeInsetsGeometry? padding;
  final VoidCallback? onPressed;

  @override
  State<ZButton> createState() => _ZButtonState();
}

class _ZButtonState extends State<ZButton> {
  @override
  Widget build(BuildContext context) {
    LinearGradient gradient = ZGradient.linearGradientBtnBlue;
    List<BoxShadow> boxShadow = ZBoxShadow.blueBoxShadow;

    switch (widget.buttonType) {
      case ButtonType.red:
        gradient = ZGradient.linearGradientBtnRed;
        boxShadow = ZBoxShadow.redBoxShadow;
        break;
      case ButtonType.blue:
        break;
      case ButtonType.gray:
        gradient = ZGradient.linearGradientBtnGray;
        boxShadow = ZBoxShadow.boxShadowGray;
        break;
      default:
    }
    return ZInkButton(
      onPressed: widget.onPressed,
      child: Container(
        height: widget.height.w,
        alignment: Alignment.center,
        padding: widget.padding,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(8.w),
          gradient: gradient,
          boxShadow: boxShadow,
        ),
        child: Text(
          widget.text,
          style: widget.style ??
              Theme.of(context)
                  .textTheme
                  .bodyLarge
                  ?.copyWith(color: Colors.white),
        ),
      ),
    );
  }
}

enum ButtonType {
  blue,
  red,
  gray,
}
